//
//  ACEMeHeaderView.m
//  ACE
//
//  Created by zhangtao on 2018/8/9.
//  Copyright © 2018年 zt.td. All rights reserved.
//

#import "ACEMeHeaderView.h"

@implementation ACEMeHeaderView
-(instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
        if ([ACEPublicTool currentRoleIsStudent]) {
            self.backgroundColor = RGB(199, 242, 212, 1);//[UIColor whiteColor];
        }else{
            self.backgroundColor = RGB(214, 239, 252, 1);
        }
        _headImgV = [[UIImageView alloc]initWithFrame:CGRectZero];
        [self addSubview:_headImgV];
        [_headImgV mas_makeConstraints:^(MASConstraintMaker *make) {
            make.center.mas_equalTo(self);
            make.width.mas_equalTo(frame.size.height/3);
            make.height.mas_equalTo(frame.size.height/3);
        }];
        _headImgV.layer.borderColor = [UIColor whiteColor].CGColor;
        _headImgV.layer.borderWidth = 2;
        _headImgV.layer.cornerRadius = frame.size.height/6;
        _headImgV.layer.masksToBounds = YES;
        _headImgV.image = [UIImage imageNamed:@"我的 dingdanicon"];
        
        _nameLab = [[UILabel alloc]initWithFrame:CGRectZero];
        [self addSubview:_nameLab];
        [_nameLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.mas_equalTo(self);
            make.top.mas_equalTo(self.headImgV.mas_bottom).mas_offset(@15);
            make.height.mas_equalTo(20);
        }];
        _nameLab.font = [UIFont systemFontOfSize:17];
        _nameLab.text = @"Anna";
        
        _editBtn = [[UIButton alloc]initWithFrame:CGRectZero];
        [self addSubview:_editBtn];
        [_editBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.mas_equalTo(self.nameLab);
            make.left.mas_equalTo(self.nameLab.mas_right).mas_offset(30);
            make.height.mas_equalTo(@25);
            make.width.mas_equalTo(25);
        }];
        [_editBtn setImage:[UIImage imageNamed:@"编辑"] forState:UIControlStateNormal];
        [_editBtn addTarget:self action:@selector(editClick) forControlEvents:UIControlEventTouchUpInside];
        
        _emailLab = [[UILabel alloc]initWithFrame:CGRectZero];
        [self addSubview:_emailLab];
        [_emailLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.mas_equalTo(self);
            make.height.mas_equalTo(@20);
            make.top.mas_equalTo(self.nameLab.mas_bottom);
        }];
        _emailLab.font = [UIFont systemFontOfSize:14];
        _emailLab.textColor = [UIColor darkGrayColor];
        _emailLab.text = @"124245@gmail.com";
    }
    return self;
}

-(void)editClick{
    if (self.editBtnClick) {
        self.editBtnClick();
    }
}


/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
